// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require(CONFIG.BasePath + "js/enterprise/base");
	var router = require("../hash/pageRouter");
	var css_main = require("./account.css");
	var constant = require("constant");
	var databind = require("databind");
	var dialog = require("dialog");
	var tools = require("tools");
	var _css = require("./warehousePickupList.css");
	var html_financeContract = require("./html_financeContract.html");
	var pickupState;
	var productTypes=6;
	var applytypes;
	var enterpriseName;
	var isProviders=false;
	var p1 = 0;
	var p2 = 0;
	var p3 = 0;
	var p4 = 0;
	var p5 = 0;
	var oData = {
		pageIndex : 1,
        pageSize : 10,
        totalPageCount : 1,
        totalRecordCount : 0,//分页初始化
        productType:productTypes,
        isProvider:1,
        pickupState: eval ("(" + pickupState + ")"),
        financeNumber:enterpriseName,
	};
	
	var init = function(page) {
		p1 = 0;
		p2 = 0;
		p3 = 0;
		p4 = 0;
		p5 = 0;
		$("#warehousePickupList .pickupQuantitys").html(0);
		$("#warehousePickupList .bulkstockAmount").html(0);
		$("#warehousePickupList .interest").html(0);
		$("#warehousePickupList .others").html(0);
		$("#warehousePickupList .pickupAmounts").html(0);
		var pageIndex = 1,
		pageSize = 10,
		totalPageCount = 1,
		totalRecordCount = 0; //分页初始化
		pickupState = page.params.pickupState || base.getUrlParam("pickupState");
		router.init();
		inquireCurrentEnterpriseDetail();
		loadPickupList(oData);
		initEvent();
	};
	var initEvent = function() {
			if (pickupState != null) {
				$("#warehousePickupList select[name=pickupState]").html("<option value='"+pickupState+"'>待办</option><option value=''>全部</option>");
			} else {
				
			}
			tools.loadSelectList($("#warehousePickupList select[name=enterpriseId]"), "inquireEnterpriseList.json", "id", "name", null);
			$("#pp1").hide();
			
			$("#accountRecordApplySearchButton").unbind("click").click(function(){				
				var ps=null;
//				if ($("#warehousePickupList select[name=pickupState]").val() != "") {
//					ps = eval ("(" + $("#wareHousePickupList select[name=pickupState]").val() + ")")
//				} else {
//					ps = "";
//				}
//				if(applytypes == "applyType2"){
					var productType=6;
					var isProvider=1;
					$("#accountRecordApplySearchButton").attr("action", $(this).attr("action"));
					$("#pp1").show();
					var oData = {
							pageIndex : 1,
					        pageSize : 10,
					        totalPageCount : 1,
					        totalRecordCount : 0,//分页初始化
					        pickupState: ps,
					        pickupNumber: $("#warehousePickupList input[name=pickupNumber]").val(),
					        creator: $("#warehousePickupList input[name=creator]").val(),
					        screatDt:$("#warehousePickupList input[name=dateBegin]").val(),
					        ecreatDt:$("#warehousePickupList input[name=dateEnd]").val(),
					        enterpriseId:$("#warehousePickupList select[name=enterpriseId]").val(),
					        buyer:$("#warehousePickupList input[name=buyer]").val(),
					        spickupDt:$("#warehousePickupList input[name=dateBegin2]").val(),
					        epickupDt:$("#warehousePickupList input[name=dateEnd2]").val(),
//					        productType:$("#warehousePickupList select[name=productType]").val(),
					        bulkstockName:$("#warehousePickupList input[name=bulkstockName]").val(),
					        productType:productType,
					        isProvider:isProvider,
					        financeNumber:$("#warehousePickupList input[name=financeNumber]").val(),
						}
//				}
//				else{
//					var productType=5;
//					var isProvider=0;
//					var oData = {
//							pageIndex : 1,
//					        pageSize : 10,
//					        totalPageCount : 1,
//					        totalRecordCount : 0,//分页初始化
//					        pickupState: ps,
//					        pickupNumber: $("#warehousePickupList input[name=pickupNumber]").val(),
//					        creator: $("#warehousePickupList input[name=creator]").val(),
//					        screatDt:$("#warehousePickupList input[name=dateBegin]").val(),
//					        ecreatDt:$("#warehousePickupList input[name=dateEnd]").val(),
//					        enterpriseId:$("#warehousePickupList select[name=enterpriseId]").val(),
//					        buyer:$("#warehousePickupList input[name=buyer]").val(),
//					        spickupDt:$("#warehousePickupList input[name=dateBegin2]").val(),
//					        epickupDt:$("#warehousePickupList input[name=dateEnd2]").val(),
////					        productType:$("#warehousePickupList select[name=productType]").val(),
//					        bulkstockName:$("#warehousePickupList input[name=bulkstockName]").val(),
//					        productType:productType,
//					        isProvider:isProvider,
//					        financeNumber:$("#warehousePickupList input[name=financeNumber]").val(),
//						}
//				}
				
				loadPickupList(oData);
				
			});
			
		$("#applyType span").click(function() {
			$("#applyType span").removeClass("active_applyType");
			$(this).addClass("active_applyType");
			$(this).parent().removeClass("applyType1").removeClass("applyType2")
			$(this).parent().addClass($(this).attr("applytype"));
			applytypes=$(this).attr("applytype");
			if(applytypes == "applyType2"){
				var productType=6;
				var isProvider=1;
				$("#accountRecordApplySearchButton").attr("action", $(this).attr("action"));
				$("#pp1").show();
				oData.isProvider=isProvider;
				oData.productType=productType;
				loadPickupList(oData);
			}else{
				var productType=5;
				var isProvider=0;
				$("#accountRecordApplySearchButton").attr("action", $(this).attr("action"));
				$("#pp1").hide();
				oData.isProvider=isProvider;
				oData.productType=productType;
				loadPickupList(oData);
			}
		});
	};
	
	var loadPickupList = function(oData) {
		 $("#warehousePickupList .outerTable").html("");
		tools.loadList("inquireFinancePickupApplicationWarehousePageList.json", $("#warehousePickupList .outerTable"), $("#warehousePickupList script"),
				oData, function(data){
			//新增代销提货
			$("#warehousePickupList .createPickup").unbind("click").click(function(){
				router.route("account/createPickup.html");
			});
			//新增代采提货
			$("#warehousePickupList .createPickup1").unbind("click").click(function(){
				router.route("account/createPickup1.html");
			});
			//初审
			$("#warehousePickupList .audit").unbind("click").click(function(){
				router.route("warehousePickup/approvelConsignment.html?pickupId="+ $(this).parents("tr").attr("pickupId"));
			});
			
			//政审
			$("#warehousePickupList .careful").unbind("click").click(function(){
				router.route("warehousePickup/approvelCarefulManage.html?pickupId="+ $(this).parents("tr").attr("pickupId"));
			});
			
			//详情
			$("#warehousePickupList .details").unbind("click").click(function(){
				var productType = $(this).parents("tr").attr("productType");
				if(productType == 6) { //代销提货
					router.route("account/createPickupDetail.html?pickupId=" + $(this).parents("tr").attr("pickupId"));
				}else if(productType == 5) { //代采提货
					router.route("account/createPickupDetail1.html?pickupId=" + $(this).parents("tr").attr("pickupId"));
				}
			});
			
			$.each(data.datas, function() {
				var _this1 = this;
				if (_this1.pickupState != 1 && _this1.pickupState != 13) {
					$.each(_this1.bulkstockList, function() {
						var _this2 = this;
						p1 = _this2.pickupQuantity*1 + p1*1;
						p2 = _this2.bulkstockAmount*1 + p2*1;
						p3 = _this2.interest*1 + p3*1;
						p4 = _this2.others*1 + p4*1;
						p5 = _this2.pickupAmount*1 + p5*1;
					});
				}
			});
			$("#warehousePickupList .pickupQuantitys").html(p1);
			$("#warehousePickupList .bulkstockAmount").html(p2);
			$("#warehousePickupList .interest").html(p3);
			$("#warehousePickupList .others").html(p4);
			$("#warehousePickupList .pickupAmounts").html(p5);
			
			//修改
			$("#warehousePickupList .update_s2").unbind("click").click(function(){
				var productType = $(this).parents("tr").attr("productType");
				var enterpriseName=$(this).parents("tr").attr("enterpriseNames");
				var buyer=$(this).parents("tr").attr("buyer");
				if(productType == 6) { //代销提货
//					if(enterpriseName == buyer){
						router.route("account/updatePickup3.html?pickupId=" + $(this).parents("tr").attr("pickupId"));
//					}else{
//						router.route("account/updatePickup.html?pickupId=" + $(this).parents("tr").attr("pickupId"));
//					}
				}else if(productType == 5) { //代采提货
					router.route("account/updatePickup1.html?pickupId=" + $(this).parents("tr").attr("pickupId"));
				}
			});
			
			//平台签署
			$("#warehousePickupList .platformSign").unbind("click").click(function(){
				var $this = $(this);
				
				ii = layer.open({
				  title: '合同信息',
				  type: 1,
				  skin: 'layui-layer-rim', //加上边框
				  area: ['1000px', '600px'], //宽高
				  content: html_documentSign,
				  btn: ['确定']
				});
				
				inquireFinancePickupApplicationWarehouse1($this.parents("tr").attr("pickupId"));
			});
			//合同签署
			$("#documentSign_s2").unbind("click").click(function(){
//        		var productType = $(this).parents("tr").attr("productType");
//				if(productType == 6) { //代销提货
					router.route("account/warehousePickupdocumentSign.html?pickupId=" + $(this).parents("tr").attr("pickupId"));
//				}else if(productType == 5) { //代采提货
//					router.route("account/warehousePickupdocumentSign.html?pickupId=" + $(this).parents("tr").attr("pickupId"));
//				}
        	});
			// 点击合同确认
			$("#warehousePickupList .contractConfirm").unbind("click").click(function() {
				var $this = $(this);
				ii = layer.open({
				  type: 1,
				  title: "合同确认",
				  skin: 'layui-layer-rim', //加上边框
				  area: ['1000px', '600px'], //宽高
				  content: html_contractConfirm,
				  btn: ['确定'],
				  yes: function(){
				  	if ($(".confirm").length > 0) {
				  		base.alert(2, "还有合同尚未确认！");
				  		return false;
				  	} else {
				  		layer.close(ii);
				  		loadPickupList(oData);
				  	}
				  },
				  cancel: function(){
				  	if ($(".confirm").length > 0) {
				  		base.alert(2, "还有合同尚未确认！");
				  		return false;
				  	} else {
				  		layer.close(ii);
				  		loadPickupList(oData);
				  	}
				  }
				});
				
				
				inquireFinancePickupApplicationWarehouse2($this.parents("tr").attr("pickupId"));
			});
			
			//提交提货
			$("#warehousePickupList .submitApplication").unbind("click").click(function(){
				var $this = $(this);
				var ii = layer.confirm('是否确认提交该条提货', {
				  btn: ['确定','取消'] //按钮
				}, function(){
					submitFinancePickupApplicationWarehouse($this.parents("tr").attr("pickupId"), function(){
						layer.close(ii);
						loadPickupList(oData);
					});
				});
			});
			$("#warehousePickupList .cancel_01").unbind("click").click(function(){
				var $this = $(this);
				var ii = layer.confirm('是否确认取消该条提货', {
				  btn: ['确定','取消'] //按钮
				}, function(){
					cancelFinancePickupApplicationWarehouse($this.parents("tr").attr("pickupId"), function(){
						layer.close(ii);
					});
				});
			});
			
			//合同提交
			$("#warehousePickupList .submit").unbind("click").click(function(){
				var $this = $(this);
				var ii = layer.confirm('是否确认提交合同', {
				  btn: ['确定','取消'] //按钮
				}, function(){
					submitPickupContract($this.parents("tr").attr("pickupId"), function(){
						layer.close(ii);
					});
				});
			});
			
			//合同上传
			$("#warehousePickupList .upload").unbind("click").click(function(){
				var $this = $(this);
				var ii = layer.open({
				  title: '上传合同',
				  type: 1,
				  skin: 'layui-layer-rim', //加上边框
				  area: ['1000px', '600px'], //宽高
				  content: html_financeContract,
				  btn: ['确定', '取消'],
				  yes: function(){
				  		databind.submitDom($(".html_financeContract"), function(){
					  		layer.msg("提交成功！");
					  		layer.close(ii);
					  		loadPickupList(oData);
					  	});
				  }
				});
				$(".html_financeContract input[name=pickupId]").val($this.parents("tr").attr("pickupId"));
				if ($(this).parents("tr").attr("pickupState") == 3) {
					inquireFinanceFilesNormList();
				} else {
					$(".html_financeContract").attr("action", "updateWarehousePickupContract");
					inquireFinancePickupApplicationWarehouse($this.parents("tr").attr("pickupId"));
				}
				
				$(".html_financeContract").on("click", ".deleteProductIntro", function() {
					var d = $(this).parent().parent().parent().parent().parent();
					$(this).parents("tr").remove();
					var fileUuid = [];
					var fileSign = [];
					for (var j = 0; j < d.find(".mas").length; j++) {
						fileUuid.push($(d.find(".mas")[j]).attr("fileUuid"));
						$(d.find(".mas")[j]).find(".fileIndex").html(j+1);
						if ($(d.find(".mas")[j]).find("input[type=checkbox]").prop("checked")) {
							fileSign.push(1);
						} else {
							fileSign.push(0);
						}
					}
					d.find("input[name=filesUuid]").val(fileUuid);
					d.find("input[name=filesSign]").val(fileSign);
				});
				
				$(".html_financeContract").on("click", "table input[type=checkbox]", function() {
					var d = $(this).parent().parent().parent().parent().parent();
					var fileSign = [];
					for (var j = 0; j < d.find("input[type=checkbox]").length; j++) {
						if ($(d.find("input[type=checkbox]")[j]).prop("checked")) {
							fileSign.push(1);
						} else {
							fileSign.push(0);
						}
					}
					d.find("input[name=filesSign]").val(fileSign);
				});
			});
			
			//解除监管
			$("#warehousePickupList .release").unbind("click").click(function(){
				var $this = $(this);
				var ii = layer.confirm('是否确认解除监管', {
				  btn: ['确定','取消'] //按钮
				}, function(){
					deregulationPickupApplicationWarehouse($this.parents("tr").attr("pickupId"), function(){
						layer.close(ii);
					});
				});
			});
		}, $("#warehousePickupList .pagerCon"));
	}
	
	//查询所需附件列表
	var inquireFinanceFilesNormList = function() {
		base.fnAjax({
			action: "inquireFinanceFilesNormList.json",
			async: false, //同步异步
			oData: {
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					var tpl = $(".html_financeContract script").html();
					var html = juicer(tpl, data);
					$(".html_financeContract .normInfos").html(html);
					
					for (var i = 0; i < $(".html_financeContract .normFileName").length; i++) {
						var $this = $("#" + $($(".html_financeContract .normFileName")[i]).attr("id"));
						tools.fileupload($this, null, function (data, dom) {
							var d = $("#" + $(dom).attr("id"));
							var str = '<tr fileUuid="'+data.result.data[0].fileUuid+'" class="mas"><td class="fileIndex"></td><td>'+data.result.data[0].fileName+'</td><td>'+d.parent().find("input[name=filesUuid]").attr("codeName")+'</td><td><input type="checkbox" value="1" /></td><td><a href="/finance/api/v1.0/viewPdfFile.json?fileUuid=' + data.result.data[0].fileUuid + '" target="_blank">预览</a> <a href="javascript:void(0);" class="deleteProductIntro">删除</a></td></tr>';
							d.parent().find("table").append(str);
							var fileUuid = [];
							var fileSign = [];
							for (var j = 0; j < d.parent().find(".mas").length; j++) {
								fileUuid.push($(d.parent().find(".mas")[j]).attr("fileUuid"));
								$(d.parent().find(".mas")[j]).find(".fileIndex").html(j+1);
								if ($(d.parent().find(".mas")[j]).find("input[type=checkbox]").prop("checked")) {
									fileSign.push(1);
								} else {
									fileSign.push(0);
								}
							}
							d.parent().find("input[name=filesUuid]").val(fileUuid);
							d.parent().find("input[name=filesSign]").val(fileSign);
						});
					};
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
	
	//查询代采代销提货详情
	var inquireFinancePickupApplicationWarehouse = function(pickupId) {
		base.fnAjax({
			action: "inquireFinancePickupApplicationWarehouse.json",
			async: false, //同步异步
			oData: {
				pickupId: pickupId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					databind.fillForm($(".html_financeContract"), data.datas[0]);
					var tpl = '{@each datas as it, index}' +
							'{@each it.financeFilesInfoList as item, index}' +
							'<div style="margin-top: 15px;">' +
							'<input type="hidden" name="filesInfoId" value="${item.filesInfoId}" />' +
							'<input isNull="${item.isNotNull}" codeName="${item.normFileName}" type="hidden" value="${item.filesUuid}" name="filesUuid" />' +
							'<input type="hidden" name="filesSign" value="${item.isSign}" />' +
							'<input type="hidden" name="fileSignState" value="${item.fileSignState}" />' +
							'<input multiple="multiple" type="file" id="normFileName${index}" name="file" class="none normFileName" />' +
							'<span class="none${item.isNotNull}" style="color: red;">*</span><span>${item.normFileName}：</span><label for="normFileName${index}" class="productIntro">添加</label>' +
							'<table style="border: none;">' +
							'	<tr>' +
							'		<th width="5%" style="padding-left: 0;">No</th>' +
							'		<th width="55%" >文件名称</th>' +
							'		<th width="10%" >附件类型</th>' +
							'		<th width="10%" >签署</th>' +
							'		<th width="20%" >操作</th>' +
							'	</tr>' +
							'</table>' +
							'</div>' +
							'{@/each}' +
							'{@/each}';
					var html = juicer(tpl, data);
					$(".html_financeContract .normInfos").html(html);
					
					$.each($(".html_financeContract input[name=filesUuid]"), function(){
						var $this1 = $(this);
						var fs1 = $this1.val().split(',');
						var ss1 = $this1.parent().find("input[name=filesSign]").val().split(',');
						var signState = $this1.parent().find("input[name=fileSignState]").val().split(',');
						for(var x = 0; x < fs1.length; x++){
							var f = fs1[x];
							if (f != "") {
								if (ss1[x] == "1") {
									if (signState[x] == 5) {
										var str = '<tr fileUuid="'+f+'" class="mas"><td class="fileIndex">'+parseInt(x+1)+'</td><td><a href="/finance/api/v1.0/downloadFile.file?fileUuid=' + f + '" target="_blank">'+tools.inquireFile(f)+'</a></td><td>'+$this1.attr("codeName")+'</td><td><input checked="checked" type="checkbox" value="1" /></td><td><a href="javascript:void(0);" class="replace">替换</a></td></tr>';
										$this1.parent().find("table").append(str);
									} else {
										var str = '<tr fileUuid="'+f+'" class="mas"><td class="fileIndex">'+parseInt(x+1)+'</td><td><a href="/finance/api/v1.0/downloadFile.file?fileUuid=' + f + '" target="_blank">'+tools.inquireFile(f)+'</a></td><td>'+$this1.attr("codeName")+'</td><td><input checked="checked" type="checkbox" value="1" /></td><td><a href="javascript:void(0);" class="deleteProductIntro">删除</a></td></tr>';
										$this1.parent().find("table").append(str);
									}
								} else {
									if (signState[x] == 5) {
										var str = '<tr fileUuid="'+f+'" class="mas"><td class="fileIndex">'+parseInt(x+1)+'</td><td><a href="/finance/api/v1.0/downloadFile.file?fileUuid=' + f + '" target="_blank">'+tools.inquireFile(f)+'</a></td><td>'+$this1.attr("codeName")+'</td><td><input type="checkbox" value="1" /></td><td><a href="javascript:void(0);" class="replace">替换</a> </td></tr>';
										$this1.parent().find("table").append(str);
									} else {
										var str = '<tr fileUuid="'+f+'" class="mas"><td class="fileIndex">'+parseInt(x+1)+'</td><td><a href="/finance/api/v1.0/downloadFile.file?fileUuid=' + f + '" target="_blank">'+tools.inquireFile(f)+'</a></td><td>'+$this1.attr("codeName")+'</td><td><input type="checkbox" value="1" /></td><td><a href="javascript:void(0);" class="deleteProductIntro">删除</a></td></tr>';
										$this1.parent().find("table").append(str);
									}
								}
							}
						};
					});
					$(".html_financeContract input[type=checkbox]").attr("disabled", "disabled");
					
					
					$(".html_financeContract .replace").unbind("click").click(function(){
						var ii = layer.open({
						  type: 1,
						  title: "合同修改",
						  skin: 'layui-layer-rim', //加上边框
						  area: ['620px', '300px'], //宽高
						  content: html_signReplace,
						  btn: ['确定', '取消'],
						  yes: function(){
						  	databind.submitDom($(".signReplace"), function(){
						  		layer.msg("修改成功！");
						  		layer.close(ii);
						  		tf = true;
						  		inquireFinancePickupApplicationWarehouse(pickupId);
						  	});
						  }
						});
						
						$(".signReplace input[name=pickupId]").val(pickupId);
						$(".signReplace input[name=oldFileUuid]").val($(this).parents("tr").attr("fileUuid"));
						tools.fileupload($("#newFile"), null, function (data, dom) {
							var str = '<a target="_blank" href="/finance/api/v1.0/downloadFile.file?fileUuid='+data.result.data[0].fileUuid+'">'+data.result.data[0].fileName+'</a>';
							$("#newFile").parent().find("span").html(str);
							$(".signReplace input[name=newFileUuid]").val(data.result.data[0].fileUuid);
						});
					});
					
					for (var i = 0; i < $(".html_financeContract .normFileName").length; i++) {
						var $this = $("#" + $($(".html_financeContract .normFileName")[i]).attr("id"));
						tools.fileupload($this, null, function (data, dom) {
							var d = $("#" + $(dom).attr("id"));
//							var str = '<div class="showProductIntroDiv"><a target="_blank" class="mas" fileUuid="' + data.result.data[0].fileUuid + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + data.result.data[0].fileUuid + '" class="showProductIntro">' + data.result.data[0].fileName + '</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="deleteProductIntro">x</a></div>'
							var str = '<tr fileUuid="'+data.result.data[0].fileUuid+'" class="mas"><td class="fileIndex"></td><td>'+data.result.data[0].fileName+'</td><td>'+d.parent().find("input[name=filesUuid]").attr("codeName")+'</td><td><input disabled="disabled" type="checkbox" value="1" /></td><td><a href="/finance/api/v1.0/viewPdfFile.json?fileUuid=' + data.result.data[0].fileUuid + '" target="_blank">预览</a> <a href="javascript:void(0);" class="deleteProductIntro">删除</a></td></tr>';
//							d.parent().find(".productIntro").before(str);
							d.parent().find("table").append(str);
							var fileUuid = [];
							var fileSign = [];
							for (var j = 0; j < d.parent().find(".mas").length; j++) {
								fileUuid.push($(d.parent().find(".mas")[j]).attr("fileUuid"));
								$(d.parent().find(".mas")[j]).find(".fileIndex").html(j+1);
								if ($(d.parent().find(".mas")[j]).find("input[type=checkbox]").prop("checked")) {
									fileSign.push(1);
								} else {
									fileSign.push(0);
								}
							}
							d.parent().find("input[name=filesUuid]").val(fileUuid);
							d.parent().find("input[name=filesSign]").val(fileSign);
						});
					};
					
					if (data.datas[0].pickupState == 8 || tf == true) {
						$(".html_financeContract .deleteProductIntro").remove();
					}
					
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
	
	//提交提货
	var submitFinancePickupApplicationWarehouse = function(pickupId, callback) {
		base.fnAjax({
			action: "submitFinancePickupApplicationWarehouse.json",
			async: false,
			oData: {
				pickupId: pickupId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					base.alert(1, "提交成功！");
					router.route("account/warehousePickupList.html");
				}else {
					base.alert(3, data.message);
				}
				callback();
			}
		});
	};
	//取消提货
	var cancelFinancePickupApplicationWarehouse = function(pickupId, callback) {
		base.fnAjax({
			action: "cancelFinancePickupApplicationWarehouse.json",
			async: false,
			oData: {
				pickupId: pickupId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					base.alert(1, "取消成功！");
					router.route("account/warehousePickupList.html");
				}else {
					base.alert(3, data.message);
				}
				callback();
			}
		});
	};
	
	//合同提交
	var submitPickupContract = function(pickupId) {
		base.fnAjax({
			action: "submitPickupContract.json",
			async: false,
			oData: {
				pickupId: pickupId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					base.alert(1, "提交成功！");
					router.route("account/warehousePickupList.html");
				}else {
					base.alert(3, data.message);
				}
			}
		});
	};
	
	//查询企业详情
	var inquireCurrentEnterpriseDetail = function() {
		base.fnAjax({
			action: "inquireCurrentEnterpriseDetail.json",
			nocode: true,
			oData: {
			
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					enterpriseName = data.datas[0].enterpriseName;	
//					$("#createPickup3 input[name=buyer]").val(data.datas[0].enterpriseName);
//					$("#createPickup3 select[name=enterpriseId]").val(data.datas[0].enterpriseId);
				}else {
					//
				}
			}
		})
	};
	
	return {
		init: init
	};
});